package com.webex.ta.hydra.function;

import com.webex.ta.hydra.exceptions.InvalidVariableException;

/**
 * Created by IntelliJ IDEA.
 * User: vegaz
 * Date: 2010-8-30
 * Time: 15:21:27
 * To change this template use File | Settings | File Templates.
 */
public class VariableReplacer {

    public static String transform(String input) throws InvalidVariableException {
        CompoundVariable master = new CompoundVariable();
        master.clear();
        master.setParameter(input);
        if (master.hasFunction()) {
            String value = master.getFunction().execute();
            if (value.equals(input))
                return input;
            else
                return transform(value);
        } else {
            return input;
        }
    }
}
